import request from '@/utils/request'

export function getComponents() {
  return request({
    url: '/components',
    method: 'get'
  })
}

export function getComponentsStock() {
  return request({
    url: '/componentsStock',
    method: 'get'
  })
}

export function createComponent(data) {
  return request({
    url: '/component',
    method: 'post',
    data: data
  })
}

export function deleteComponent(id) {
  return request({
    url: '/component/' + id,
    method: 'delete'
  })
}

export function updateComponent(id, data) {
  return request({
    url: '/component/' + id,
    method: 'patch',
    data: data
  })
}

export function getComponentsAsAdmin() {
  return request({
    url: '/admin/components',
    method: 'get'
  })
}
